package com.dr.springboot.starter.util;

import com.dr.springboot.starter.VO.ResultVO;
import com.dr.springboot.starter.enums.ResultEnum;

/**
 * Created by rui on 2018/7/25.
 */
//todo pattern 对返回值统一进行包装
public class ResultVOUtil {

    public static <T> ResultVO success(T data) {
        ResultVO<T> resultVO = new ResultVO<T>();
        resultVO.setCode(ResultEnum.SUCCESS.getCode());
        resultVO.setMessage(ResultEnum.SUCCESS.getMessage());
        resultVO.setData(data);
        return resultVO;
    }

    public static <T> ResultVO error(ResultEnum resultEnum) {
        ResultVO<T> resultVO = new ResultVO<T>();
        resultVO.setCode(resultEnum.getCode());
        resultVO.setMessage(resultEnum.getMessage());
        return resultVO;
    }
}
